package gui;

import gui.GUI;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;


public class PanelKunde extends JPanel implements ActionListener {
	private JButton buttonNyKunde, buttonEksisterendeKunde, buttonHovedmeny;
	private GridBagConstraints constraints;
	private JLabel labelVelgKundeType;
	public PanelKunde(){
		this.setLayout(new GridBagLayout());
		this.leggTilKnapper();
		GUI.getVindu().add(this);
	}
	private void leggTilKnapper(){
		
		buttonNyKunde = new JButton("Ny kunde");
		buttonNyKunde.addActionListener(this);
		
		buttonEksisterendeKunde = new JButton("Eksisterende kunde");
		buttonEksisterendeKunde.addActionListener(this);
		
		buttonHovedmeny = new JButton("Tilbake til hovedmeny");
		buttonHovedmeny.addActionListener(this);
		
		labelVelgKundeType = new JLabel("Velg kundetype");
		Font f = new Font(labelVelgKundeType.getFont().getName(), labelVelgKundeType.getFont().getStyle(), 30);
		labelVelgKundeType.setFont(f);
		
		
		
		constraints = new GridBagConstraints();
		constraints.insets = new Insets(10,10,10,10);
		constraints.gridwidth = 3;
		this.add(labelVelgKundeType, constraints);
		constraints.gridwidth = 1;
		constraints.gridy = 1;
		constraints.gridx = 1;
		constraints.ipadx = 60;
		constraints.ipady = 30;
		this.add(buttonNyKunde,constraints);
		constraints.gridx = 2;
		this.add(buttonEksisterendeKunde,constraints);
		constraints.ipadx = 30;
		constraints.ipady = 15;
		constraints.gridwidth = 2;
		constraints.gridx = 1;
		constraints.gridy = 2;
		this.add(buttonHovedmeny,constraints);
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource()==buttonNyKunde)
			buttonNyKunde_actionPerformed(e);
		else if(e.getSource()==buttonEksisterendeKunde)
			buttonEksisterendeKunde_actionPerformed(e);
		else if(e.getSource()==buttonHovedmeny)
			buttonTilbake_actionPerformed(e);

	}

	private void buttonNyKunde_actionPerformed(ActionEvent e)
	{
		this.setVisible(false);
		new PanelNyKunde();		
	}

	private void buttonEksisterendeKunde_actionPerformed(ActionEvent e)
	{
		this.setVisible(false);
		new PanelEksisterendeKunde();
	}
	private void buttonTilbake_actionPerformed(ActionEvent e) {
		this.setVisible(false);
		new PanelHovedmeny();
		
	}

}
